<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Manager - Draw Operations</title>
    </h:head>
    <h:body>
        <ui:include src="../header.xhtml"/>
        <hr/>
        <h:messages style="color: red"></h:messages>
        <f:view>
            <h:panelGrid columns="2" border="0">
                <h:form>
                    <h:panelGrid columns="2">
                        <f:facet name="header">
                            <h:outputText value="Teams"/>
                        </f:facet>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Home Team"/>
                            </f:facet>
                            <h:commandLink value="#{drawManagedBean.current.homeTeam}"
                                           action="#{teamManagedBean.linkTeam(drawManagedBean.current.homeTeam)}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Away Team"/>
                            </f:facet>
                            <h:commandLink value="#{drawManagedBean.current.awayTeam}"
                                           action="#{teamManagedBean.linkTeam(drawManagedBean.current.awayTeam)}"/>
                        </h:column>
                    </h:panelGrid>
                </h:form>
                <h:form>
                    <h:panelGrid columns="2" border ="0">
                        <f:facet name="header">
                            <h:outputText value="Draws"/>
                        </f:facet>
                        <h:column>
                            <h:commandLink value="#{drawManagedBean.homeDraw}"
                                           action="#{drawManagedBean.linkDraw(drawManagedBean.homeDraw,drawManagedBean.tournament)}"/>
                        </h:column>
                        <h:column>
                            <h:commandLink value="#{drawManagedBean.awayDraw}"
                                           action="#{drawManagedBean.linkDraw(drawManagedBean.awayDraw,drawManagedBean.tournament)}"/>
                        </h:column>
                    </h:panelGrid>
                </h:form>
            </h:panelGrid>
            <h:panelGrid columns="4" border="0" rendered="#{drawManagedBean.creatingMatchAllowed}">
                <f:facet name="header">
                    <h:outputText value="CREATE MATCH"/>
                </f:facet>
                <h:form>
                    <h:panelGrid columns="3" border="0">
                        <h:outputLabel for="mDate" value="Date"/>
                        <h:inputText id="mDate" value="#{drawManagedBean.mDate}" required="true" requiredMessage="*">
                            <f:convertDateTime pattern="yyyy-MM-dd" for="mDate" type="date"/>
                        </h:inputText>
                        <h:message for="mDate" style="color: red"/>

                        <h:outputLabel for="mTime" value="Time"/>
                        <h:inputText id="mTime" value="#{drawManagedBean.mTime}" required="true" requiredMessage="*"/>
                        <h:message for="mTime" style="color: red"/>

                        <h:commandButton value="Create" action="#{drawManagedBean.createMatch}"/>
                    </h:panelGrid>
                </h:form>
                <h:panelGrid>
                    <h:form>
                        <h:dataTable value="#{drawManagedBean.mReferees}" var="item" rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Referees"/>
                                </f:facet>
                                <h:outputText value="#{item}"/>
                            </h:column>
                            <h:column>
                                <h:commandLink value="Remove" action="#{drawManagedBean.removeReferee(item)}"/>
                            </h:column>
                        </h:dataTable>
                    </h:form>
                    <h:form>
                        <h:dataTable value="#{drawManagedBean.refereeList}" var="item"  rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Other Referees"/>
                                </f:facet>
                                <h:outputText value="#{item}"/>
                            </h:column>
                            <h:column>
                                <h:commandLink value="Add" action="#{drawManagedBean.addReferee(item)}"/>
                            </h:column>
                        </h:dataTable>
                    </h:form>

                </h:panelGrid>
                <h:panelGrid>
                    <h:form>
                        <h:dataTable value="#{drawManagedBean.mUmpires}" var="item"  rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Umpires"/>
                                </f:facet>
                                <h:outputText value="#{item}"/>
                            </h:column>
                            <h:column>
                                <h:commandLink value="Remove" action="#{drawManagedBean.removeUmpire(item)}"/>
                            </h:column>
                        </h:dataTable>
                    </h:form>
                    <h:form>
                        <h:dataTable value="#{drawManagedBean.umpireList}" var="item"  rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Other Umpires"/>
                                </f:facet>
                                <h:outputText value="#{item}"/>
                            </h:column>
                            <h:column>
                                <h:commandLink value="Add" action="#{drawManagedBean.addUmpire(item)}"/>
                            </h:column>
                        </h:dataTable>
                    </h:form>
                </h:panelGrid>
                <h:form>
                    <h:panelGrid columns="1">
                        <f:facet name="header">
                            <h:outputText value="ASSIGN COURT"/>
                        </f:facet>
                        <h:dataTable value="#{drawManagedBean.courtList}" var="item" rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                            <h:column>
                                <h:outputText value="#{item}"/>
                            </h:column>
                            <h:column>
                                <h:commandLink value="Assign" action="#{drawManagedBean.assignCourt(item)}"
                                               rendered="#{drawManagedBean.canAssignCourt(item)}"/>
                            </h:column>
                        </h:dataTable>
                    </h:panelGrid>
                </h:form>
            </h:panelGrid>
        </f:view>
    </h:body>
</html>

